package cn.iocoder.yudao.module.handguard.controller.admin.publicitynotice;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;

import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*;

import cn.iocoder.yudao.module.handguard.controller.admin.publicitynotice.vo.*;
import cn.iocoder.yudao.module.handguard.dal.dataobject.publicitynotice.PublicityNoticeDO;
import cn.iocoder.yudao.module.handguard.convert.publicitynotice.PublicityNoticeConvert;
import cn.iocoder.yudao.module.handguard.service.publicitynotice.PublicityNoticeService;

@Tag(name = "管理后台 - 通用公示")
@RestController
@RequestMapping("/general/publicity-notice")
@Validated
public class PublicityNoticeController {

    @Resource
    private PublicityNoticeService publicityNoticeService;

    @GetMapping("/commonList")
    @Operation(summary = "用户协议隐私政策/公示公告....列表")
    public CommonResult<List<PublicityNoticeRespVO>> getCommonList(String classify) {
        List<PublicityNoticeDO> list = publicityNoticeService.getCommonList(classify);
        return success(PublicityNoticeConvert.INSTANCE.convertList(list));
    }

    @GetMapping("/get")
    @Operation(summary = "获得通用公示详情")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<PublicityNoticeRespVO> getPublicityNotice(@RequestParam("id") Long id) {
        PublicityNoticeDO publicityNotice = publicityNoticeService.getPublicityNotice(id);
        return success(PublicityNoticeConvert.INSTANCE.convert(publicityNotice));
    }

    @PutMapping("/update")
    @Operation(summary = "更新编辑")
    @PreAuthorize("@ss.hasPermission('general:publicity-notice:update')")
    public CommonResult<Boolean> updatePublicityNotice(@Valid @RequestBody PublicityNoticeUpdateReqVO updateReqVO) {
        publicityNoticeService.updatePublicityNotice(updateReqVO);
        return success(true);
    }


    //@GetMapping("/notice")
    //@Operation(summary = "公示公告")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:query')")
    //public CommonResult<List<PublicityNoticeRespVO>> getPublicityNoticeList() {
    //    List<PublicityNoticeDO> list = publicityNoticeService.getPublicityNoticeList(ids);
    //    return success(PublicityNoticeConvert.INSTANCE.convertList(list));
    //}


    //@PostMapping("/create")
    //@Operation(summary = "创建通用公示")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:create')")
    //public CommonResult<Long> createPublicityNotice(@Valid @RequestBody PublicityNoticeCreateReqVO createReqVO) {
    //    return success(publicityNoticeService.createPublicityNotice(createReqVO));
    //}
    //
    //@PutMapping("/update")
    //@Operation(summary = "更新通用公示")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:update')")
    //public CommonResult<Boolean> updatePublicityNotice(@Valid @RequestBody PublicityNoticeUpdateReqVO updateReqVO) {
    //    publicityNoticeService.updatePublicityNotice(updateReqVO);
    //    return success(true);
    //}
    //
    //@DeleteMapping("/delete")
    //@Operation(summary = "删除通用公示")
    //@Parameter(name = "id", description = "编号", required = true)
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:delete')")
    //public CommonResult<Boolean> deletePublicityNotice(@RequestParam("id") Long id) {
    //    publicityNoticeService.deletePublicityNotice(id);
    //    return success(true);
    //}



    //@GetMapping("/list")
    //@Operation(summary = "获得通用公示列表")
    //@Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:query')")
    //public CommonResult<List<PublicityNoticeRespVO>> getPublicityNoticeList(@RequestParam("ids") Collection<Long> ids) {
    //    List<PublicityNoticeDO> list = publicityNoticeService.getPublicityNoticeList(ids);
    //    return success(PublicityNoticeConvert.INSTANCE.convertList(list));
    //}

    //@GetMapping("/page")
    //@Operation(summary = "获得通用公示分页")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:query')")
    //public CommonResult<PageResult<PublicityNoticeRespVO>> getPublicityNoticePage(@Valid PublicityNoticePageReqVO pageVO) {
    //    PageResult<PublicityNoticeDO> pageResult = publicityNoticeService.getPublicityNoticePage(pageVO);
    //    return success(PublicityNoticeConvert.INSTANCE.convertPage(pageResult));
    //}

    //@GetMapping("/export-excel")
    //@Operation(summary = "导出通用公示 Excel")
    //@PreAuthorize("@ss.hasPermission('general:publicity-notice:export')")
    //@OperateLog(type = EXPORT)
    //public void exportPublicityNoticeExcel(@Valid PublicityNoticeExportReqVO exportReqVO,
    //          HttpServletResponse response) throws IOException {
    //    List<PublicityNoticeDO> list = publicityNoticeService.getPublicityNoticeList(exportReqVO);
    //    // 导出 Excel
    //    List<PublicityNoticeExcelVO> datas = PublicityNoticeConvert.INSTANCE.convertList02(list);
    //    ExcelUtils.write(response, "通用公示.xls", "数据", PublicityNoticeExcelVO.class, datas);
    //}

}
